﻿using System;
using System.Collections.Generic;
using System.Text;
using XCore.Authorization;

namespace SaaS.Core.Authorization
{
    public class PermissionSystemProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var site = context.CreatePermission(PermissionNames.Site, "平台管理");

            var tenant = site.CreateChildPermission(PermissionNames.Site_Tenant, "租户管理");
            tenant.CreateChildPermission(PermissionNames.Site_Tenant_Query, "查看");
            tenant.CreateChildPermission(PermissionNames.Site_Tenant_ResetPwd, "修改密码");
            tenant.CreateChildPermission(PermissionNames.Site_Tenant_Login, "登录租户系统");

            var operation = site.CreateChildPermission(PermissionNames.Site_Operation, "运营平台");

            var order = site.CreateChildPermission(PermissionNames.Site_Order, "订单管理");

            var project = site.CreateChildPermission(PermissionNames.Site_Project, "产品管理");
            project.CreateChildPermission(PermissionNames.Site_Project_Create, "创建");
            project.CreateChildPermission(PermissionNames.Site_Project_Edit, "编辑");
            project.CreateChildPermission(PermissionNames.Site_Project_Delete, "删除");
            project.CreateChildPermission(PermissionNames.Site_Project_Query, "查看");
            project.CreateChildPermission(PermissionNames.Site_Project_Authoriza, "授权");
            project.CreateChildPermission(PermissionNames.Site_Project_Release, "发布产品");



            var gateway = context.CreatePermission(PermissionNames.Gateway, "门户管理");

            var basics = gateway.CreateChildPermission(PermissionNames.Gateway_Basics, "基础设置");
            basics.CreateChildPermission(PermissionNames.Gateway_Basics_Create, "创建");
            basics.CreateChildPermission(PermissionNames.Gateway_Basics_Edit, "编辑");
            basics.CreateChildPermission(PermissionNames.Gateway_Basics_Delete, "删除");
            basics.CreateChildPermission(PermissionNames.Gateway_Basics_Query, "查看");

            var notic = gateway.CreateChildPermission(PermissionNames.Gateway_Notice, "新闻公告");
            notic.CreateChildPermission(PermissionNames.Gateway_Notice_Create, "创建");
            notic.CreateChildPermission(PermissionNames.Gateway_Notice_Edit, "编辑");
            notic.CreateChildPermission(PermissionNames.Gateway_Notice_Delete, "删除");
            notic.CreateChildPermission(PermissionNames.Gateway_Notice_Query, "查看");

            var log = context.CreatePermission(PermissionNames.Log, "日志管理");
            log.CreateChildPermission(PermissionNames.Log_System, "审计日志");
            log.CreateChildPermission(PermissionNames.Log_Login, "登录日志");
            log.CreateChildPermission(PermissionNames.Log_File, "文件日志");
            log.CreateChildPermission(PermissionNames.Log_Error, "错误日志");
            log.CreateChildPermission(PermissionNames.Log_Trace, "跟踪日志");
            log.CreateChildPermission(PermissionNames.Log_Scheduler, "服务日志");

            var system = context.CreatePermission(PermissionNames.System, "系统管理");
            var database = system.CreateChildPermission(PermissionNames.System_Database, "数据库管理");
        }
    }
}
